home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_31 / s.asm < prev    next >
Assembly Source File  |  1995-01-01  |  55KB  |  1,623 lines

  1. ideal
  2. P286
  3. model   Huge
  4. jumps
  5.  
  6. stack   1024
  7.  
  8. segment MyCode
  9.  
  10. include         "gusmod.inc"
  11.  
  12. NumNotes        = 36
  13. NoteX1          = 4
  14. NoteY1          = 7
  15. NoteX2          = 73
  16. NoteY2          = 7
  17. StartLine       = 7
  18. StartX          = 8
  19. EfxX            = 8
  20. EfxY            = 2
  21. Spacing         = 5
  22. freek_Line      = 24
  23. freek_Col       = 69
  24.  
  25. struc   SampleRec
  26. sname           db      16h dup (?)
  27. length          dw      ?
  28. volume          dw      ?
  29. repeat          dw      ?
  30. replen          dw      ?
  31. ends    SampleRec
  32.  
  33. struc   HS
  34. songname        db      20 dup (?)
  35. samples         db      31*size SampleRec dup (?)
  36. songlen         db      ?
  37. restart         db      ?
  38. sequences       db      128 dup (?)
  39. mk              dd      ?
  40. ends    HS
  41.  
  42.  
  43.  
  44.                 assume  cs:MyCode,ds:MyData
  45.  
  46. MMus            SMus    <>
  47. Music           dw      0,BlankMusicSeg
  48. P               PM      <>
  49.  
  50. PspAddress      dw      0
  51. SizeOfProg      dw      0
  52.  
  53. Num             db      '00',13,10,'$'
  54.  
  55. include "display.asm"
  56. include "modload2.asm"
  57. include "files.asm"
  58. include "sd.asm"
  59. include "env.asm"
  60.  
  61. proc            Terminate near
  62.                 mov     bx,5
  63.                 call    [dword ptr cs:Music]
  64.                 mov     bx,6            ; Kill music.
  65.                 call    [dword ptr cs:Music]
  66.                 call    MUS_KillModule
  67.                 mov     bx,1            ; Close down player.
  68.                 call    [dword ptr cs:Music]
  69.                 mov     ax,MyData
  70.                 mov     ds,ax
  71.                 mov     ah,0Eh
  72.                 mov     dl,[OldDrive]
  73.                 int     21h
  74.                 mov     ah,3Bh
  75.                 mov     dx,offset HomeDirectory - 1
  76.                 int     21h
  77.                 mov     es,[Word FileSeg+2]
  78.                 mov     ah,49h
  79.                 int     21h
  80.                 mov     es,[Word cs:ScreenFix]
  81.                 mov     ah,49h
  82.                 int     21h
  83.                 call    FreeSoundDriver
  84.                 call    RestoreMode
  85.                 mov     ax,4C00h
  86.                 int     21h
  87. endp            Terminate
  88.  
  89. proc            Error near
  90.                 mov     ax,MyData
  91.                 mov     ds,ax
  92.                 mov     ah,9
  93.                 int     21h
  94.                 mov     ah,0
  95.                 int     16h
  96.                 call    Terminate
  97. endp            Error
  98.  
  99. ; si - Filename offset
  100. proc            PutName
  101.                 push    ds es
  102.                 mov     ax,MyData
  103.                 mov     es,ax
  104.                 mov     di,[es:PutFilename]
  105.                 mov     ax,cs
  106.                 mov     ds,ax
  107.                 mov     cx,12
  108.                 rep     movsb
  109.                 mov     al,0
  110.                 stosb
  111.                 pop     es ds
  112.                 ret
  113. endp            PutName
  114.  
  115. assume          ds:MyData
  116.  
  117. proc            DrawDots
  118.                 mov     ax,[cs:ScreenFix]
  119.                 mov     es,ax
  120.                 mov     di,StartLine*160+StartX*2
  121.                 mov     bx,36
  122.                 mov     si,0
  123. @@LineLoop:     push    di
  124.                 cmp     si,Spacing
  125.                 jnz     @@DrawIt
  126.                 mov     ax,07F9h
  127.                 mov     cx,64
  128.                 rep     stosw
  129.                 mov     si,0
  130.                 jmp     @@Bottom
  131. @@DrawIt:       mov     cx,64
  132.                 mov     dx,0
  133. @@PutLoop:      mov     ax,03FAh
  134.                 cmp     dx,Spacing
  135.                 jnz     @@JustPut
  136.                 mov     ax,07F9h
  137.                 mov     dx,0
  138. @@JustPut:      stosw
  139.                 inc     dx
  140.                 loop    @@PutLoop
  141. @@Bottom:       inc     si
  142.                 pop     di
  143.                 add     di,160
  144.                 dec     bx
  145.                 jnz     @@LineLoop
  146.                 ret
  147. endp            DrawDots
  148.  
  149. proc            DrawNotes near
  150.                 push    ds
  151.                 mov     ax,MyData
  152.                 mov     ds,ax
  153.                 mov     ax,[cs:ScreenFix]
  154.                 mov     es,ax
  155.                 mov     si,offset Notes
  156.                 mov     di,NoteY1*160+NoteX1*2
  157.                 mov     bx,offset KeyName
  158.                 mov     bp,-4
  159.                 call    DrawNotes1
  160.                 mov     si,offset Notes
  161.                 mov     di,NoteY2*160+NoteX2*2
  162.                 mov     bx,offset KeyName
  163.                 mov     bp,8
  164.                 call    DrawNotes1
  165.                 pop     ds
  166.                 ret
  167. DrawNotes1:     mov     cx,36
  168.                 mov     dx,0
  169. @@DrawThem:     mov     ah,0Bh
  170.                 cmp     dx,Spacing
  171.                 jnz     @@DLoop
  172.                 mov     dx,0
  173.                 mov     ah,0Fh
  174. @@DLoop:        push    cx di
  175.                 mov     cx,3
  176. @@DrawLoop:     lodsb
  177.                 stosw
  178.                 loop    @@DrawLoop
  179.                 pop     di cx
  180.                 mov     al,[cs:bx]
  181.                 mov     [es:di+bp],ax
  182.                 inc     bx
  183.                 add     di,160
  184.                 inc     dx
  185.                 loop    @@DrawThem
  186.                 ret
  187. endp            DrawNotes
  188.  
  189. Matcher         dw      113,120,127,135,143,151,160,170,180,190,202,214
  190.                 dw      226,240,254,269,285,302,320,339,360,381,404,428
  191.                 dw      453,480,508,538,570,604,640,678,720,762,808,856
  192. proc            NoteMatch
  193.                 mov     ax,[si]
  194.                 xchg    ah,al
  195.                 and     ax,0FFFh
  196.                 or      ax,ax
  197.                 jz      @@Done
  198.                 mov     bx,offset Matcher
  199.                 mov     cx,0
  200. @@NoteMatcher:  inc     cx
  201.                 add     bx,2
  202.                 cmp     ax,[cs:bx]
  203.                 jge     @@NoteMatcher
  204.                 mov     ax,cx
  205. @@Done:         ret
  206. endp            NoteMatch
  207.  
  208. ; AX - Attribute
  209. ; DX - Attribute New Note
  210. ; BX - Pattern
  211. ; CX - Channel to draw (0-15)
  212. Line            dw      0
  213. OldOne          dw      0
  214. Attr            dw      0
  215. AttrNew         dw      0
  216. proc            DrawPattern
  217.                 push    ds es bx
  218.                 mov     [cs:Attr],ax
  219.                 mov     [cs:AttrNew],dx
  220.                 xor     bh,bh
  221.                 mov     bl,[cs:bx+sequences]
  222.                 shl     bx,1
  223.                 mov     ax,[cs:bx+PatternLoc]
  224.                 mov     ds,ax
  225.                 mov     si,0
  226.                 shl     cx,2
  227.                 add     si,cx
  228.                 mov     ax,[cs:ScreenFix]
  229.                 mov     es,ax
  230.                 mov     di,StartLine*160+StartX*2
  231.                 mov     [Word cs:Line],0
  232.                 mov     [Word cs:OldOne],0
  233. @@DrawNotes:    call    NoteMatch
  234.                 or      ax,ax
  235.                 jz      @@DrawNext
  236.                 mov     [cs:OldOne],ax
  237.                 dec     ax
  238.                 mov     bx,160
  239.                 mul     bx
  240.                 add     ax,[cs:Line]
  241.                 add     ax,[cs:Line]
  242.                 mov     di,StartLine*160+StartX*2
  243.                 add     di,ax
  244.                 mov     ax,[cs:AttrNew]
  245.                 stosw
  246.                 jmp     @@Skip
  247. @@DrawNext:     cmp     [Word cs:OldOne],0
  248.                 jz      @@Skip
  249.                 mov     ax,[cs:Attr]
  250.                 stosw
  251. @@Skip:         add     si,16
  252.                 inc     [Word cs:Line]
  253.                 cmp     [Word cs:Line],64
  254.                 jnz     @@DrawNotes
  255.                 pop     bx es ds
  256.                 ret
  257. endp            DrawPattern
  258.  
  259. InsDisp         db      ' 0123456789ABCDEFGHIJKLMNOPQRSTU'
  260. EfxDisp         db      ' 0123456789ABCDEF'
  261. proc            DrawEfx
  262.                 push    ds es bx
  263.                 xor     bh,bh
  264.                 mov     bl,[cs:bx+sequences]
  265.                 shl     bx,1
  266.                 mov     ax,[cs:bx+PatternLoc]
  267.                 mov     ds,ax
  268.                 mov     si,0
  269.                 shl     cx,2
  270.                 add     si,cx
  271.                 mov     ax,[cs:ScreenFix]
  272.                 mov     es,ax
  273.                 mov     di,EfxY*160+EfxX*2
  274.                 mov     [Word cs:Line],0
  275. @@DrawIns:      push    di
  276.                 mov     bl,[si+2]
  277.                 and     bl,0F0h
  278.                 shr     bl,4
  279.                 mov     bh,[si]
  280.                 and     bh,0F0h
  281.                 or      bl,bh
  282.                 xor     bh,bh
  283.                 mov     al,[cs:bx+InsDisp]
  284.                 mov     ah,0Fh
  285.                 mov     [es:di],ax
  286.                 add     di,160
  287.                 xor     bh,bh
  288.                 mov     bl,[si+2]
  289.                 and     bx,0Fh
  290.                 mov     cl,[si+3]
  291.                 or      bl,bl
  292.                 jnz     @@OKEfx
  293.                 or      cx,cx
  294.                 jz      @@ClrEfx
  295. @@OKEfx:        mov     al,[cs:bx+EfxDisp+1]
  296.                 mov     [es:di],ax
  297.                 add     di,160
  298.                 mov     bl,cl
  299.                 shr     bl,4
  300.                 mov     al,[cs:bx+EfxDisp+1]
  301.                 mov     [es:di],ax
  302.                 add     di,160
  303.                 mov     bl,cl
  304.                 and     bl,0Fh
  305.                 mov     al,[cs:bx+EfxDisp+1]
  306.                 mov     [es:di],ax
  307.                 add     di,160
  308.                 jmp     @@EndLoop
  309. @@ClrEfx:       mov     cx,3
  310.                 mov     al,' '
  311. @@ClrEfxLoop:   mov     [es:di],ax
  312.                 add     di,160
  313.                 loop    @@ClrEfxLoop
  314. @@EndLoop:      add     si,16
  315.                 pop     di
  316.                 add     di,2
  317.                 inc     [Word cs:Line]
  318.                 cmp     [Word cs:Line],64
  319.                 jnz     @@DrawIns
  320.                 pop     bx es ds
  321.                 ret
  322. endp            DrawEfx
  323.  
  324. proc            DrawAllTop
  325.                 call    DrawAll
  326.                 mov     cx,1
  327.                 call    PlotXYTop
  328.                 ret
  329. endp            DrawAllTop
  330.  
  331. proc            DrawAllBot
  332.                 call    DrawAll
  333.                 mov     cx,1
  334.                 call    PlotXYBot
  335.                 ret
  336. endp            DrawAllBot
  337.  
  338. proc            DrawAll
  339.                 call    DrawDots
  340.                 mov     bx,[cs:CurPat]
  341.                 mov     cx,[cs:CurChannel]
  342.                 call    DrawEfx
  343.                 mov     cx,0
  344. @@ChannelWrite: cmp     cx,[cs:CurChannel]
  345.                 jz      @@BottomLoop
  346.                 mov     ax,07DCh
  347.                 mov     dx,07DCh
  348.                 push    cx
  349.                 call    DrawPattern
  350.                 pop     cx
  351. @@BottomLoop:   inc     cx
  352.                 cmp     cx,4
  353.                 jnz     @@ChannelWrite
  354.                 mov     dx,4F20h
  355.                 mov     ax,0FDBh
  356.                 mov     bx,[cs:CurPat]
  357.                 mov     cx,[cs:CurChannel]
  358.                 call    DrawPattern
  359.                 push    ds es
  360.                 mov     ds,[cs:ScreenFix]
  361.                 mov     es,[cs:Screen]
  362.                 mov     si,0
  363.                 mov     di,0
  364.                 mov     cx,4000
  365.                 rep     movsw
  366.                 pop     es ds
  367.                 ret
  368. endp            DrawAll
  369.  
  370. OldAttr         dw      0
  371. OldCoord        dw      8002
  372. OldCoordBot2    dw      8002
  373. OffBot          db      0
  374. proc            PlotXYBot
  375.                 mov     ax,[cs:CurY]
  376.                 mov     bx,160
  377.                 mul     bx
  378.                 add     ax,[cs:CurX]
  379.                 add     ax,[cs:CurX]
  380.                 mov     bx,[cs:Screen]
  381.                 mov     es,bx
  382.                 mov     di,StartLine*160+StartX*2
  383.                 add     di,ax
  384.                 or      cx,cx
  385.                 jnz     @@Skip
  386.                 mov     bx,[cs:OldCoordBot2]
  387.                 add     bx,2*160+8*2+1
  388.                 mov     cx,4
  389. @@RowLoop:      xor     [Byte es:bx],00010000b
  390.                 add     bx,160
  391.                 loop    @@RowLoop
  392.                 mov     bx,[cs:OldCoord]
  393.                 mov     ax,[cs:OldAttr]
  394.                 mov     [es:bx],ax
  395. @@Skip:         mov     ax,[es:di]
  396.                 mov     [cs:OldAttr],ax
  397.                 mov     [cs:OldCoord],di
  398.                 mov     ax,[cs:CurX]
  399.                 add     ax,[cs:CurX]
  400.                 mov     [cs:OldCoordBot2],ax
  401.                 cmp     [Byte cs:OffBot],1
  402.                 jz      @@Below
  403.                 mov     bx,ax
  404.                 add     bx,2*160+8*2+1
  405.                 mov     cx,4
  406. @@RowLoop2:     xor     [Byte es:bx],00010000b
  407.                 add     bx,160
  408.                 loop    @@RowLoop2
  409.                 mov     [Word es:di],9ADBh
  410. @@Below:        ret
  411. endp            PlotXYBot
  412.  
  413. OldAttrTop      dw      0
  414. OldCoordTop     dw      8002
  415. OldCoordTop2    dw      8002
  416. OffTop          db      0
  417. proc            PlotXYTop
  418.                 mov     ax,[cs:CurYTop]
  419.                 mov     bx,160
  420.                 mul     bx
  421.                 add     ax,[cs:CurX]
  422.                 add     ax,[cs:CurX]
  423.                 mov     bx,[cs:Screen]
  424.                 mov     es,bx
  425.                 mov     di,EfxY*160+EfxX*2
  426.                 add     di,ax
  427.                 or      cx,cx
  428.                 jnz     @@Skip
  429.                 mov     bx,[cs:OldCoordTop2]
  430.                 add     bx,7*160+8*2+1
  431.                 mov     cx,36
  432. @@RowLoop:      xor     [Byte es:bx],00010000b
  433.                 add     bx,160
  434.                 loop    @@RowLoop
  435.                 mov     bx,[cs:OldCoordTop]
  436.                 mov     ax,[cs:OldAttrTop]
  437.                 mov     [es:bx],ax
  438. @@Skip:         mov     ax,[es:di]
  439.                 mov     [cs:OldAttrTop],ax
  440.                 mov     [cs:OldCoordTop],di
  441.                 mov     ax,[cs:CurX]
  442.                 add     ax,[cs:CurX]
  443.                 mov     [cs:OldCoordTop2],ax
  444.                 cmp     [Byte cs:OffTop],1
  445.                 jz      @@Below
  446.                 mov     bx,ax
  447.                 add     bx,7*160+8*2+1
  448.                 mov     cx,36
  449. @@RowLoop2:     xor     [Byte es:bx],00010000b
  450.                 add     bx,160
  451.                 loop    @@RowLoop2
  452.                 mov     [Word es:di],9ADBh
  453. @@Below:        ret
  454. endp            PlotXYTop
  455.  
  456. proc            SetNote
  457.                 push    ds
  458.                 mov     bx,[cs:CurPat]
  459.                 xor     bh,bh
  460.                 mov     bl,[cs:bx+sequences]
  461.                 shl     bx,1
  462.                 mov     ax,[cs:bx+PatternLoc]
  463.                 mov     ds,ax
  464.                 mov     si,0
  465.                 mov     cx,[cs:CurChannel]
  466.                 shl     cx,2
  467.                 add     si,cx
  468.                 mov     cx,[cs:CurX]
  469.                 shl     cx,4
  470.                 add     si,cx
  471.                 mov     bx,[cs:CurY]
  472.                 shl     bx,1
  473.                 mov     ax,[cs:bx+Matcher]
  474.                 xchg    ah,al
  475.                 and     [Word si],00F0h
  476.                 or      [Word si],ax
  477.                 pop     ds
  478.                 ret
  479. endp            SetNote
  480.  
  481. proc            DelNote
  482.                 push    ds
  483.                 mov     bx,[cs:CurPat]
  484.                 xor     bh,bh
  485.                 mov     bl,[cs:bx+sequences]
  486.                 shl     bx,1
  487.                 mov     ax,[cs:bx+PatternLoc]
  488.                 mov     ds,ax
  489.                 mov     si,[cs:CurChannel]
  490.                 shl     si,2
  491.                 mov     cx,[cs:CurX]
  492.                 shl     cx,4
  493.                 add     si,cx
  494.                 and     [Word si],00F0h
  495.                 pop     ds
  496.                 ret
  497. endp            DelNote
  498.  
  499. proc            InsertCol
  500.                 push    ds es
  501.                 std
  502.                 mov     bx,[cs:CurPat]
  503.                 xor     bh,bh
  504.                 mov     bl,[cs:bx+sequences]
  505.                 shl     bx,1
  506.                 mov     ax,[cs:bx+PatternLoc]
  507.                 mov     ds,ax
  508.                 mov     es,ax
  509.                 mov     cx,[cs:CurChannel]
  510.                 shl     cx,2
  511.                 mov     di,1024-16
  512.                 add     di,cx
  513.                 mov     si,1024-32
  514.                 add     si,cx
  515.                 mov     cx,63
  516.                 sub     cx,[cs:CurX]
  517. @@CopyLoop:     mov     ax,[si]
  518.                 mov     [di],ax
  519.                 mov     ax,[si+2]
  520.                 mov     [di+2],ax
  521.                 sub     di,16
  522.                 sub     si,16
  523.                 loop    @@CopyLoop
  524.                 mov     si,[cs:CurChannel]
  525.                 shl     si,2
  526.                 mov     cx,[cs:CurX]
  527.                 shl     cx,4
  528.                 add     si,cx
  529.                 mov     [Word si],0
  530.                 mov     [Word si+2],0
  531.                 cld
  532.                 pop     es ds
  533.                 ret
  534. endp            InsertCol
  535.  
  536. proc            DeleteCol
  537.                 push    ds es
  538.                 cld
  539.                 mov     bx,[cs:CurPat]
  540.                 xor     bh,bh
  541.                 mov     bl,[cs:bx+sequences]
  542.                 shl     bx,1
  543.                 mov     ax,[cs:bx+PatternLoc]
  544.                 mov     ds,ax
  545.                 mov     es,ax
  546.                 mov     di,[cs:CurChannel]
  547.                 shl     di,2
  548.                 mov     cx,[cs:CurX]
  549.                 shl     cx,4
  550.                 add     di,cx
  551.                 mov     si,di
  552.                 add     si,16
  553.                 mov     cx,63
  554.                 sub     cx,[cs:CurX]
  555. @@CopyLoop:     mov     ax,[si]
  556.                 mov     [di],ax
  557.                 mov     ax,[si+2]
  558.                 mov     [di+2],ax
  559.                 add     di,16
  560.                 add     si,16
  561.                 loop    @@CopyLoop
  562.                 mov     [Word di],0
  563.                 mov     [Word di+2],0
  564.                 pop     es ds
  565.                 ret
  566. endp            DeleteCol
  567.  
  568. proc            UpcaseKey
  569.                 cmp     al,'a'
  570.                 jb      @@NoKey
  571.                 cmp     al,'z'
  572.                 ja      @@NoKey
  573.                 and     al,01011111b
  574. @@NoKey:        ret
  575. endp            UpcaseKey
  576.  
  577. proc            GetAddr
  578.                 mov     bx,[cs:CurPat]
  579.                 xor     bh,bh
  580.                 mov     bl,[cs:bx+sequences]
  581.                 shl     bx,1
  582.                 mov     ax,[cs:bx+PatternLoc]
  583.                 mov     ds,ax
  584.                 mov     si,[cs:CurChannel]
  585.                 shl     si,2
  586.                 mov     cx,[cs:CurX]
  587.                 shl     cx,4
  588.                 add     si,cx
  589.                 ret
  590. endp            GetAddr
  591.  
  592. proc            CheckOtherKeys near
  593.                 push    ds
  594.                 call    UpcaseKey
  595.                 cmp     [Word cs:CurYTop],0
  596.                 jnz     @@Row2
  597.                 mov     bx,0
  598. @@ScanKey1:     cmp     al,[cs:bx+InsDisp]
  599.                 jz      @@FoundKey1
  600.                 inc     bx
  601.                 cmp     bx,32
  602.                 jnz     @@ScanKey1
  603.                 jmp     @@NoFind
  604. @@FoundKey1:    mov     dx,bx
  605.                 call    GetAddr
  606.                 and     [Word si],0FF0Fh
  607.                 and     [Byte si+2],0Fh
  608.                 mov     ax,dx
  609.                 shr     al,4
  610.                 or      [Byte si],al
  611.                 shl     dl,4
  612.                 or      [Byte si+2],dl
  613.                 jmp     @@Find
  614. ;──────────────────────────────────────────────────
  615. @@Row2:         cmp     [Word cs:CurYTop],1
  616.                 jnz     @@Row3
  617.                 call    ScanKeys
  618.                 or      bx,bx
  619.                 jz      @@Clear
  620.                 dec     bx
  621. @@JustNormal:   mov     dx,bx
  622.                 call    GetAddr
  623.                 and     [Byte si+2],0F0h
  624.                 or      [Byte si+2],dl
  625.                 jmp     @@Find
  626. @@Clear:        call    GetAddr
  627.                 and     [Byte si+2],0F0h
  628.                 mov     [Byte si+3],0
  629.                 jmp     @@Find
  630. ;──────────────────────────────────────────────────
  631. @@Row3:         cmp     [Word cs:CurYTop],2
  632.                 jnz     @@Row4
  633.                 call    ScanKeys
  634.                 or      bx,bx
  635.                 jz      @@JustNormal2
  636.                 dec     bx
  637. @@JustNormal2:  mov     dx,bx
  638.                 call    GetAddr
  639.                 and     [Byte si+3],0Fh
  640.                 shl     dl,4
  641.                 or      [Byte si+3],dl
  642.                 jmp     @@Find
  643. ;──────────────────────────────────────────────────
  644. @@Row4:         call    ScanKeys
  645.                 or      bx,bx
  646.                 jz      @@JustNormal3
  647.                 dec     bx
  648. @@JustNormal3:  mov     dx,bx
  649.                 call    GetAddr
  650.                 and     [Byte si+3],0F0h
  651.                 or      [Byte si+3],dl
  652.                 jmp     @@Find
  653. @@Find:         cmp     [Byte cs:CurX],63
  654.                 jz      @@JustDraw
  655.                 inc     [Byte cs:CurX]
  656. @@JustDraw:     call    DrawAllTop
  657. @@NoFind:       pop     ds
  658.                 ret
  659. ScanKeys:       mov     bx,0
  660. ScanKeyLoop:    cmp     al,[cs:bx+EfxDisp]
  661.                 jz      FoundKey
  662.                 inc     bx
  663.                 cmp     bx,17
  664.                 jnz     ScanKeyLoop
  665.                 pop     ax
  666.                 jmp     @@NoFind
  667. FoundKey:       ret
  668. endp            CheckOtherKeys
  669.  
  670. proc            PlayMusic
  671.                 mov     ax,-1
  672.                 mov     [Word cs:offset P+(offset (PM).mt_speed)],ax
  673.                 mov     ax,-1
  674.                 mov     [Word cs:offset P+(offset (PM).mt_counter)],ax
  675.                 mov     ax,[cs:CurX]
  676.                 shl     ax,4
  677.                 mov     [Word cs:offset P+(offset (PM).mt_PatternPos)],ax
  678.                 mov     ax,[cs:CurPat]
  679.                 mov     [Word cs:offset P+(offset (PM).mt_SongPos)],ax
  680.                 mov     cx,cs
  681.                 mov     si,offset P
  682.                 mov     bx,4
  683.                 call    [dword ptr cs:Music]
  684.                 mov     [cs:OldPos],0FFFFh
  685.                 ret
  686. endp            PlayMusic
  687.  
  688.  
  689. CurYTop         dw      0
  690. proc            DoItTop
  691. TopPart:        mov     cx,0
  692.                 call    PlotXYTop
  693. TopLooper:      mov     ah,0
  694.                 int     16h
  695. ;──────────────────────────────────────────────────────────
  696. @@Key_AltL:     cmp     ax,2600h
  697.                 jne     @@Key_Tab
  698.                 call    LoadFile
  699.                 call    DrawAllBot
  700.                 jmp     @@End
  701. ;──────────────────────────────────────────────────────────
  702. @@Key_Tab:      cmp     al,9
  703.                 jne     @@Key_Up
  704.                 mov     [Byte cs:OffTop],1
  705.                 call    DrawAllBot
  706.                 mov     [Byte cs:OffTop],0
  707.                 jmp     BottomPart
  708. ;──────────────────────────────────────────────────────────
  709. @@Key_Up:       cmp     ah,72
  710.                 jne     @@Key_Down
  711.                 cmp     [Word cs:CurYTop],0
  712.                 je      @@Key_Up_1
  713.                 dec     [Word cs:CurYTop]
  714.                 mov     cx,0
  715.                 call    PlotXYTop
  716. @@Key_Up_1:     jmp     @@End
  717. ;──────────────────────────────────────────────────────────
  718. @@Key_Down:     cmp     ah,80
  719.                 jne     @@Key_Left
  720.                 cmp     [Word cs:CurYTop],3
  721.                 je      @@Key_Down_1
  722.                 inc     [Word cs:CurYTop]
  723.                 mov     cx,0
  724.                 call    PlotXYTop
  725. @@Key_Down_1:   jmp     @@End
  726. ;──────────────────────────────────────────────────────────
  727. @@Key_Left:     cmp     ah,75
  728.                 jne     @@Key_Right
  729.                 cmp     [Word cs:CurX],0
  730.                 je      @@Key_Left_1
  731.                 dec     [Word cs:CurX]
  732.                 mov     cx,0
  733.                 call    PlotXYTop
  734. @@Key_Left_1:   jmp     @@End
  735. ;──────────────────────────────────────────────────────────
  736. @@Key_Right:    cmp     ah,77
  737.                 jne     @@Key_Del
  738.                 cmp     [Word cs:CurX],63
  739.                 je      @@Key_Right_1
  740.                 inc     [Word cs:CurX]
  741.                 mov     cx,0
  742.                 call    PlotXYTop
  743. @@Key_Right_1:  jmp     @@End
  744. ;──────────────────────────────────────────────────────────
  745. @@Key_Del:      cmp     ah,83
  746.                 jnz     @@Key_PgUp
  747.                 mov     al,32
  748.                 jmp     @@CheckOther
  749. ;──────────────────────────────────────────────────────────
  750. @@Key_PgUp:     cmp     ah,73
  751.                 jnz     @@Key_PgDn
  752.                 cmp     [Word cs:CurYTop],0
  753.                 je      @@Key_PgUp_1
  754.                 mov     [Word cs:CurYTop],0
  755.                 mov     cx,0
  756.                 call    PlotXYTop
  757. @@Key_PgUp_1:   jmp     @@End
  758. ;──────────────────────────────────────────────────────────
  759. @@Key_PgDn:     cmp     ah,81
  760.                 jnz     @@Key_Home
  761.                 cmp     [Word cs:CurYTop],3
  762.                 je      @@Key_PgDn_1
  763.                 mov     [Word cs:CurYTop],3
  764.                 mov     cx,0
  765.                 call    PlotXYTop
  766. @@Key_PgDn_1:   jmp     @@End
  767. ;──────────────────────────────────────────────────────────
  768. @@Key_Home:     cmp     ah,71
  769.                 jnz     @@Key_End
  770.                 cmp     [Word cs:CurX],0
  771.                 je      @@Key_Home_1
  772.                 mov     [Word cs:CurX],0
  773.                 mov     cx,0
  774.                 call    PlotXYTop
  775. @@Key_Home_1:   jmp     @@End
  776. ;──────────────────────────────────────────────────────────
  777. @@Key_End:      cmp     ah,79
  778.                 jnz     @@Key_CLeft
  779.                 cmp     [Word cs:CurX],63
  780.                 je      @@Key_End_1
  781.                 mov     [Word cs:CurX],63
  782.                 mov     cx,0
  783.                 call    PlotXYTop
  784. @@Key_End_1:    jmp     @@End
  785. ;──────────────────────────────────────────────────────────
  786. @@Key_CLeft:    cmp     ah,115
  787.                 jnz     @@Key_CRight
  788.                 call    DeleteCol
  789.                 call    DrawAllTop
  790.                 jmp     @@End
  791. ;──────────────────────────────────────────────────────────
  792. @@Key_CRight:   cmp     ah,116
  793.                 jnz     @@Key_F9
  794.                 call    InsertCol
  795.                 call    DrawAllTop
  796.                 jmp     @@End
  797. ;──────────────────────────────────────────────────────────
  798. @@Key_F9:       cmp     ah,67
  799.                 jnz     @@Key_F10
  800.                 cmp     [Word cs:CurPat],0
  801.                 jz      @@Key_F9_1
  802.                 dec     [Word cs:CurPat]
  803.                 call    DrawAllTop
  804. @@Key_F9_1:     jmp     @@End
  805. ;──────────────────────────────────────────────────────────
  806. @@Key_F10:      cmp     ah,68
  807.                 jnz     @@Key_1
  808.                 xor     ah,ah
  809.                 mov     al,[cs:songlen]
  810.                 dec     ax
  811.                 cmp     [cs:CurPat],ax
  812.                 jz      @@Key_F10_1
  813.                 inc     [Word cs:CurPat]
  814.                 call    DrawAllTop
  815. @@Key_F10_1:    jmp     @@End
  816. ;──────────────────────────────────────────────────────────
  817. @@Key_1:        cmp     ah,3Bh
  818.                 jnz     @@Key_2
  819.                 mov     [Word cs:CurChannel],0
  820.                 call    DrawAllTop
  821.                 jmp     @@End
  822. ;──────────────────────────────────────────────────────────
  823. @@Key_2:        cmp     ah,3Ch
  824.                 jnz     @@Key_3
  825.                 mov     [Word cs:CurChannel],1
  826.                 call    DrawAllTop
  827.                 jmp     @@End
  828. ;──────────────────────────────────────────────────────────
  829. @@Key_3:        cmp     ah,3Dh
  830.                 jnz     @@Key_4
  831.                 mov     [Word cs:CurChannel],2
  832.                 call    DrawAllTop
  833.                 jmp     @@End
  834. ;──────────────────────────────────────────────────────────
  835. @@Key_4:        cmp     ah,3Eh
  836.                 jnz     @@Key_Enter
  837.                 mov     [Word cs:CurChannel],3
  838.                 call    DrawAllTop
  839.                 jmp     @@End
  840. ;──────────────────────────────────────────────────────────
  841. @@Key_Enter:    cmp     al,13
  842.                 jnz     @@Key_Esc
  843.                 call    PlayMusic
  844.                 call    DoItTrack
  845.                 call    DrawAllTop
  846.                 jmp     @@End
  847. ;──────────────────────────────────────────────────────────
  848. @@Key_Esc:      cmp     ah,1
  849.                 jnz     @@CheckOther
  850.                 ret
  851. ;──────────────────────────────────────────────────────────
  852. @@CheckOther:   call    CheckOtherKeys
  853. @@End:          jmp     TopLooper
  854. endp            DoItTop
  855.  
  856. OldPos          dw      0FFFFh
  857. ; CX - 1  Erase and Draw
  858. ; CX - 0  Erase
  859. proc            PlotTrack
  860. @@AAA:          mov     ax,[cs:offset MMus+(offset (SMus).EditOfs)]
  861.                 cmp     [cs:OldPos],ax
  862.                 jne     @@OKTrack
  863.                 ret
  864. @@OKTrack:      mov     [cs:OldPos],ax
  865.                 mov     ax,[cs:offset MMus+(offset (SMus).EditOfs)]
  866.                 shr     ax,4
  867.                 mov     [cs:CurX],ax
  868.                 mov     [cs:CurX],ax
  869.                 mov     ax,[cs:offset MMus+(offset (SMus).EditPat)]
  870.                 mov     [cs:CurPat],ax
  871.                 call    DrawAll
  872. @@NoRedraw:     mov     ax,[cs:offset MMus+(offset (SMus).EditOfs)]
  873.                 shr     ax,4
  874.                 add     ax,ax
  875.                 mov     bx,[cs:Screen]
  876.                 mov     es,bx
  877.                 mov     di,EfxY*160+EfxX*2+1
  878.                 add     di,ax
  879.                 mov     cx,41
  880. @@RowLoop:      xor     [Byte es:di],00010000b
  881.                 add     di,160
  882.                 loop    @@RowLoop
  883. @@Below:        ret
  884. endp            PlotTrack
  885.  
  886. proc            GetInfo
  887.                 mov     bx,9
  888.                 mov     cx,1
  889.                 mov     si,seg MMus
  890.                 mov     di,offset MMus
  891.                 call    [dword cs:Music]
  892.                 ret
  893. endp            GetInfo
  894.  
  895. proc            SetInfo
  896.                 mov     bx,0Ah
  897.                 mov     si,seg MMus
  898.                 mov     di,offset MMus
  899.                 call    [dword cs:Music]
  900.                 ret
  901. endp            SetInfo
  902.  
  903. proc            DoItTrack
  904.                 call    GetInfo
  905.                 mov     cx,00000010b
  906.                 call    SetInfo
  907. TrackLooper:    call    GetInfo
  908.                 call    PlotTrack
  909.                 mov     ah,1
  910.                 int     16h
  911.                 jnz     @@KeyHit
  912.                 jmp     TrackLooper
  913. @@KeyHit:       mov     ah,0
  914.                 int     16h
  915. ;──────────────────────────────────────────────────────────
  916. @@Key_AltL:     cmp     ax,2600h
  917.                 jne     @@Key_Home
  918.                 call    LoadFile
  919.                 call    PlayMusic
  920.                 jmp     @@End
  921. ;──────────────────────────────────────────────────────────
  922. @@Key_Home:     cmp     ah,71
  923.                 jnz     @@Key_End
  924.                 mov     [Word cs:offset MMus+(offset (SMus).mt_PatternPos)],0
  925.                 mov     cx,00000010b
  926.                 call    SetInfo
  927.                 call    PlotTrack
  928.                 jmp     @@End
  929. ;──────────────────────────────────────────────────────────
  930. @@Key_End:      cmp     ah,79
  931.                 jnz     @@Key_F9
  932.                 mov     [Word cs:offset MMus+(offset (SMus).mt_PatternPos)],3F0h
  933.                 mov     cx,00000010b
  934.                 call    SetInfo
  935.                 call    PlotTrack
  936.                 jmp     @@End
  937. ;──────────────────────────────────────────────────────────
  938. @@Key_F9:       cmp     ah,67
  939.                 jnz     @@Key_F10
  940.                 cmp     [Byte cs:MMus+(offset (SMus).mt_SongPos)],0
  941.                 je      @@Key_F9_1
  942.                 dec     [Byte cs:offset MMus+(offset (SMus).mt_SongPos)]
  943. @@Key_F9_1:     mov     [Word cs:offset MMus+(offset (SMus).mt_PatternPos)],0
  944.                 mov     cx,00000010b
  945.                 call    SetInfo
  946.                 call    PlotTrack
  947.                 jmp     @@End
  948. ;──────────────────────────────────────────────────────────
  949. @@Key_F10:      cmp     ah,68
  950.                 jnz     @@Key_1
  951.                 mov     al,[cs:songlen]
  952.                 dec     al
  953.                 cmp     [cs:offset MMus+(offset (SMus).mt_SongPos)],al
  954.                 je      @@Key_F10_1
  955.                 inc     [Byte cs:offset MMus+(offset (SMus).mt_SongPos)]
  956. @@Key_F10_1:    mov     [Word cs:offset MMus+(offset (SMus).mt_PatternPos)],0
  957.                 mov     cx,00000010b
  958.                 call    SetInfo
  959.                 call    PlotTrack
  960.                 jmp     @@End
  961. ;──────────────────────────────────────────────────────────
  962. @@Key_1:        cmp     ah,3Bh
  963.                 jnz     @@Key_2
  964.                 mov     [Word cs:CurChannel],0
  965.                 call    DrawAllBot
  966.                 jmp     @@End
  967. ;──────────────────────────────────────────────────────────
  968. @@Key_2:        cmp     ah,3Ch
  969.                 jnz     @@Key_3
  970.                 mov     [Word cs:CurChannel],1
  971.                 call    DrawAllBot
  972.                 jmp     @@End
  973. ;──────────────────────────────────────────────────────────
  974. @@Key_3:        cmp     ah,3Dh
  975.                 jnz     @@Key_4
  976.                 mov     [Word cs:CurChannel],2
  977.                 call    DrawAllBot
  978.                 jmp     @@End
  979. ;──────────────────────────────────────────────────────────
  980. @@Key_4:        cmp     ah,3Eh
  981.                 jnz     @@Key_Enter
  982.                 mov     [Word cs:CurChannel],3
  983.                 call    DrawAllBot
  984.                 jmp     @@End
  985. ;──────────────────────────────────────────────────────────
  986. @@Key_Enter:    cmp     al,13
  987.                 jnz     @@Key_Esc
  988. @@Key_Quit:     mov     cx,cs
  989.                 mov     si,offset P
  990.                 mov     bx,5
  991.                 call    [dword ptr cs:Music]
  992.                 ret
  993. ;──────────────────────────────────────────────────────────
  994. @@Key_Esc:      cmp     ah,1
  995.                 jnz     @@End
  996.                 jmp     @@Key_Quit
  997. ;──────────────────────────────────────────────────────────
  998. @@End:          jmp     TrackLooper
  999. endp            DoItTrack
  1000.  
  1001.  
  1002.  
  1003. ;2 1111111 111
  1004. ;0 9876543 21098 7654321
  1005. ;E F#G#A#B C#D#E F#G#A#B
  1006. ;   3 4 5   7 8   0 - =
  1007. ;Q W E R T Y U I O P [ ]
  1008. ;33333 3322222 2222
  1009. ;65432 1098765 4321
  1010. ;C#D#E F#G#A#B C#D#
  1011. ; S D   G H J   L ;
  1012. ;Z X C V B N M , .
  1013. KeyName         db      ']=[-P0OI8U7YT5R4E3WQ;.L,MJNHBGVCDXSZ'
  1014.                         ;ES  1  2  3  4  5  6  7  8  9  0  -  =  BSTB
  1015. Keys            db     0, 0, 0, 0,18,16,14, 0,11, 9, 0, 6, 4, 2, 0, 0
  1016.                        ; Q  W  E  R  T  Y  U  I  O  P  [  ] EN CT
  1017.                 db      20,19,17,15,13,12,10, 8, 7, 5, 3, 1, 0, 0
  1018.                        ; A  S  D  F  G  H  J  K  L  ;  '  ` LS
  1019.                 db       0,35,33, 0,30,28,26, 0,23,21, 0, 0, 0
  1020.                        ; \  Z  X  C  V  B  N  M  ,  .  /
  1021.                 db       0,36,34,32,31,29,27,25,24,22, 0
  1022.                 db       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1023.                 db      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1024.  
  1025. proc            CheckKeys
  1026.                 xor     bh,bh
  1027.                 mov     bl,ah
  1028.                 mov     al,[cs:bx+Keys]
  1029.                 or      al,al
  1030.                 jz      @@Exit
  1031.                 xor     ah,ah
  1032.                 dec     ax
  1033.                 mov     [cs:CurY],ax
  1034.                 call    SetNote
  1035.                 call    DrawAllBot
  1036. @@Exit:         ret
  1037. endp            CheckKeys
  1038.  
  1039. CurPat          dw      0
  1040. CurChannel      dw      0
  1041. CurX            dw      0
  1042. CurY            dw      0
  1043. DefaultIns      db      0
  1044. proc            DoIt
  1045.                 call    DrawAllBot
  1046. BottomPart:     mov     cx,0
  1047.                 call    PlotXYBot
  1048. BottomLooper:   mov     ah,0
  1049.                 int     16h
  1050. ;──────────────────────────────────────────────────────────
  1051. @@Key_AltL:     cmp     ax,2600h
  1052.                 jne     @@Key_Tab
  1053.                 call    LoadFile
  1054.                 call    DrawAllBot
  1055.                 jmp     @@End
  1056. ;──────────────────────────────────────────────────────────
  1057. @@Key_Tab:      cmp     al,9
  1058.                 jne     @@Key_Up
  1059.                 mov     [Byte cs:OffBot],1
  1060.                 call    DrawAllTop
  1061.                 mov     [Byte cs:OffBot],0
  1062.                 jmp     TopPart
  1063. ;──────────────────────────────────────────────────────────
  1064. @@Key_Up:       cmp     ah,72
  1065.                 jne     @@Key_Down
  1066.                 cmp     [Word cs:CurY],0
  1067.                 je      @@Key_Up_1
  1068.                 dec     [Word cs:CurY]
  1069.                 mov     cx,0
  1070.                 call    PlotXYBot
  1071. @@Key_Up_1:     jmp     @@End
  1072. ;──────────────────────────────────────────────────────────
  1073. @@Key_Down:     cmp     ah,80
  1074.                 jne     @@Key_Left
  1075.                 cmp     [Word cs:CurY],35
  1076.                 je      @@Key_Down_1
  1077.                 inc     [Word cs:CurY]
  1078.                 mov     cx,0
  1079.                 call    PlotXYBot
  1080. @@Key_Down_1:   jmp     @@End
  1081. ;──────────────────────────────────────────────────────────
  1082. @@Key_Left:     cmp     ah,75
  1083.                 jne     @@Key_Right
  1084.                 cmp     [Word cs:CurX],0
  1085.                 je      @@Key_Left_1
  1086.                 dec     [Word cs:CurX]
  1087.                 mov     cx,0
  1088.                 call    PlotXYBot
  1089. @@Key_Left_1:   jmp     @@End
  1090. ;──────────────────────────────────────────────────────────
  1091. @@Key_Right:    cmp     ah,77
  1092.                 jne     @@Key_Space
  1093.                 cmp     [Word cs:CurX],63
  1094.                 je      @@Key_Right_1
  1095.                 inc     [Word cs:CurX]
  1096.                 mov     cx,0
  1097.                 call    PlotXYBot
  1098. @@Key_Right_1:  jmp     @@End
  1099. ;──────────────────────────────────────────────────────────
  1100. @@Key_Space:    cmp     al,' '
  1101.                 jnz     @@Key_Del
  1102.                 call    SetNote
  1103.                 call    DrawAllBot
  1104.                 jmp     @@End
  1105. ;──────────────────────────────────────────────────────────
  1106. @@Key_Del:      cmp     ah,83
  1107.                 jnz     @@Key_PgUp
  1108.                 call    DelNote
  1109.                 call    DrawAllBot
  1110.                 jmp     @@End
  1111. ;──────────────────────────────────────────────────────────
  1112. @@Key_PgUp:     cmp     ah,73
  1113.                 jnz     @@Key_PgDn
  1114.                 cmp     [Word cs:CurY],0
  1115.                 je      @@Key_PgUp_1
  1116.                 mov     [Word cs:CurY],0
  1117.                 mov     cx,0
  1118.                 call    PlotXYBot
  1119. @@Key_PgUp_1:   jmp     @@End
  1120. ;──────────────────────────────────────────────────────────
  1121. @@Key_PgDn:     cmp     ah,81
  1122.                 jnz     @@Key_Home
  1123.                 cmp     [Word cs:CurY],35
  1124.                 je      @@Key_PgDn_1
  1125.                 mov     [Word cs:CurY],35
  1126.                 mov     cx,0
  1127.                 call    PlotXYBot
  1128. @@Key_PgDn_1:   jmp     @@End
  1129. ;──────────────────────────────────────────────────────────
  1130. @@Key_Home:     cmp     ah,71
  1131.                 jnz     @@Key_End
  1132.                 cmp     [Word cs:CurX],0
  1133.                 je      @@Key_Home_1
  1134.                 mov     [Word cs:CurX],0
  1135.                 mov     cx,0
  1136.                 call    PlotXYBot
  1137. @@Key_Home_1:   jmp     @@End
  1138. ;──────────────────────────────────────────────────────────
  1139. @@Key_End:      cmp     ah,79
  1140.                 jnz     @@Key_CLeft
  1141.                 cmp     [Word cs:CurX],63
  1142.                 je      @@Key_End_1
  1143.                 mov     [Word cs:CurX],63
  1144.                 mov     cx,0
  1145.                 call    PlotXYBot
  1146. @@Key_End_1:    jmp     @@End
  1147. ;──────────────────────────────────────────────────────────
  1148. @@Key_CLeft:    cmp     ah,115
  1149.                 jnz     @@Key_CRight
  1150.                 call    DeleteCol
  1151.                 call    DrawAllBot
  1152.                 jmp     @@End
  1153. ;──────────────────────────────────────────────────────────
  1154. @@Key_CRight:   cmp     ah,116
  1155.                 jnz     @@Key_F9
  1156.                 call    InsertCol
  1157.                 call    DrawAllBot
  1158.                 jmp     @@End
  1159. ;──────────────────────────────────────────────────────────
  1160. @@Key_F9:       cmp     ah,67
  1161.                 jnz     @@Key_F10
  1162.                 cmp     [Word cs:CurPat],0
  1163.                 jz      @@Key_F9_1
  1164.                 dec     [Word cs:CurPat]
  1165.                 call    DrawAllBot
  1166. @@Key_F9_1:     jmp     @@End
  1167. ;──────────────────────────────────────────────────────────
  1168. @@Key_F10:      cmp     ah,68
  1169.                 jnz     @@Key_1
  1170.                 xor     ah,ah
  1171.                 mov     al,[cs:songlen]
  1172.                 dec     ax
  1173.                 cmp     [cs:CurPat],ax
  1174.                 jz      @@Key_F10_1
  1175.                 inc     [Word cs:CurPat]
  1176.                 call    DrawAllBot
  1177. @@Key_F10_1:    jmp     @@End
  1178. ;──────────────────────────────────────────────────────────
  1179. @@Key_1:        cmp     ah,3Bh
  1180.                 jnz     @@Key_2
  1181.                 mov     [Word cs:CurChannel],0
  1182.                 call    DrawAllBot
  1183.                 jmp     @@End
  1184. ;──────────────────────────────────────────────────────────
  1185. @@Key_2:        cmp     ah,3Ch
  1186.                 jnz     @@Key_3
  1187.                 mov     [Word cs:CurChannel],1
  1188.                 call    DrawAllBot
  1189.                 jmp     @@End
  1190. ;──────────────────────────────────────────────────────────
  1191. @@Key_3:        cmp     ah,3Dh
  1192.                 jnz     @@Key_4
  1193.                 mov     [Word cs:CurChannel],2
  1194.                 call    DrawAllBot
  1195.                 jmp     @@End
  1196. ;──────────────────────────────────────────────────────────
  1197. @@Key_4:        cmp     ah,3Eh
  1198.                 jnz     @@Key_Enter
  1199.                 mov     [Word cs:CurChannel],3
  1200.                 call    DrawAllBot
  1201.                 jmp     @@End
  1202. ;──────────────────────────────────────────────────────────
  1203. @@Key_Enter:    cmp     al,13
  1204.                 jnz     @@Key_Esc
  1205.                 call    PlayMusic
  1206.                 call    DoItTrack
  1207.                 call    DrawAllBot
  1208.                 jmp     @@End
  1209. ;──────────────────────────────────────────────────────────
  1210. @@Key_Esc:      cmp     ah,1
  1211.                 jnz     @@CheckKeys
  1212.                 ret
  1213. ;──────────────────────────────────────────────────────────
  1214. @@CheckKeys:    call    CheckKeys
  1215. @@End:          jmp     BottomLooper
  1216. endp            DoIt
  1217.  
  1218.  
  1219. proc            LoadFile
  1220.                 call    FileSelect
  1221.                 jb      @@EndError
  1222.                 mov     cx,cs
  1223.                 mov     si,offset P
  1224.                 mov     bx,5
  1225.                 call    [dword ptr cs:Music]
  1226.                 push    es dx
  1227.                 call    MUS_KillModule
  1228.                 pop     dx cx
  1229.                 call    MUS_LoadModule
  1230.                 call    GetInfo
  1231.                 mov     [Byte cs:offset MMus+(offset (SMus).mt_speed)],6
  1232.                 mov     [Byte cs:offset MMus+(offset (SMus).mt_counter)],5
  1233.                 mov     cx,0
  1234.                 call    SetInfo
  1235.                 mov     [Word cs:CurPat],0
  1236.                 mov     [Word cs:CurX],0
  1237.                 mov     [Word cs:CurY],0
  1238.                 mov     [Word cs:CurYTop],0
  1239.                 mov     [Word cs:CurChannel],0
  1240. @@End:          clc
  1241.                 ret
  1242. @@EndError:     stc
  1243.                 ret
  1244. endp            LoadFile
  1245.  
  1246. proc            FileSelect
  1247.                 mov     di,55
  1248.                 mov     bx,0
  1249.                 mov     ah,1Fh
  1250.                 mov     al,1
  1251.                 mov     cx,24
  1252.                 mov     dx,50
  1253.                 call    DrawBox
  1254.                 call    DisplayAll
  1255.                 mov     ax,MyData
  1256.                 mov     ds,ax
  1257. @@TopLoop:      mov     ah,0
  1258.                 int     16h
  1259. ;──────────────────────────────────────────────────────────
  1260. @@Key_AltL:     cmp     ax,2600h
  1261.                 jne     @@Key_Up
  1262.                 call    FileSelect
  1263.  
  1264. ;──────────────────────────────────────────────────────────
  1265. @@Key_Up:       cmp     ah,72
  1266.                 jne     @@Key_Down
  1267.                 cmp     [Word CurFile],0
  1268.                 jz      @@Beep
  1269.                 dec     [Word CurFile]
  1270.                 mov     bx,[CurFile]
  1271.                 sub     bx,[TopFile]
  1272.                 jns     @@PrintIt
  1273.                 dec     [Word TopFile]
  1274.                 jmp     @@PrintIt
  1275. ;──────────────────────────────────────────────────────────
  1276. @@Key_Down:     cmp     ah,80
  1277.                 jne     @@Key_Home
  1278.                 mov     bx,[NumFiles]
  1279.                 dec     bx
  1280.                 cmp     [CurFile],bx
  1281.                 jz      @@Beep
  1282.                 inc     [Word CurFile]
  1283.                 mov     bx,[CurFile]
  1284.                 sub     bx,[TopFile]
  1285.                 cmp     bx,47
  1286.                 jl      @@PrintIt
  1287.                 inc     [Word TopFile]
  1288.                 jmp     @@PrintIt
  1289. ;──────────────────────────────────────────────────────────
  1290. @@Key_Home:     cmp     ah,71
  1291.                 jne     @@Key_End
  1292.                 cmp     [Word CurFile],0
  1293.                 jnz     @@SetTop
  1294.                 cmp     [Word TopFile],0
  1295.                 jz      @@Beep
  1296. @@SetTop:       mov     [Word CurFile],0
  1297.                 mov     [Word TopFile],0
  1298.                 jmp     @@PrintIt
  1299. ;──────────────────────────────────────────────────────────
  1300. @@Key_End:      cmp     ah,79
  1301.                 jne     @@Key_PgUp
  1302.                 mov     bx,[NumFiles]
  1303.                 dec     bx
  1304.                 cmp     [CurFile],bx
  1305.                 jnz     @@SetBottom
  1306.                 sub     bx,[TopFile]
  1307.                 cmp     bx,47
  1308.                 jl      @@Beep
  1309. @@SetBottom:    mov     bx,[NumFiles]
  1310.                 dec     bx
  1311.                 mov     [CurFile],bx
  1312.                 sub     bx,46
  1313.                 js      @@FixBottom
  1314.                 mov     [TopFile],bx
  1315.                 jmp     @@PrintIt
  1316. @@FixBottom:    mov     [Word TopFile],0
  1317.                 jmp     @@PrintIt
  1318. ;──────────────────────────────────────────────────────────
  1319. @@Key_PgUp:     cmp     ah,73
  1320.                 jne     @@Key_PgDn
  1321.                 cmp     [Word CurFile],0
  1322.                 jz      @@Beep
  1323.                 sub     [Word CurFile],47
  1324.                 js      @@FixPgUp
  1325.                 sub     [Word TopFile],47
  1326.                 js      @@FixPgUp2
  1327.                 jmp     @@PrintIt
  1328. @@FixPgUp:      mov     [Word CurFile],0
  1329. @@FixPgUp2:     mov     [Word TopFile],0
  1330.                 jmp     @@PrintIt
  1331. ;──────────────────────────────────────────────────────────
  1332. @@Key_PgDn:     cmp     ah,81
  1333.                 jne     @@Key_Enter
  1334.                 mov     dx,[NumFiles]
  1335.                 dec     dx
  1336.                 cmp     [CurFile],dx
  1337.                 jz      @@Beep
  1338.                 add     [Word CurFile],47
  1339.                 cmp     [CurFile],dx
  1340.                 jg      @@FixPgDn
  1341.                 add     [Word TopFile],47
  1342.                 cmp     [Word TopFile],dx
  1343.                 jg      @@FixPgDn2
  1344.                 jmp     @@PrintIt
  1345. @@FixPgDn:      mov     [Word CurFile],dx
  1346. @@FixPgDn2:     sub     dx,46
  1347.                 js      @@FixPgDn3
  1348.                 mov     [TopFile],dx
  1349.                 jmp     @@PrintIt
  1350. @@FixPgDn3:     mov     [Word TopFile],0
  1351.                 jmp     @@PrintIt
  1352. ;──────────────────────────────────────────────────────────
  1353. @@Key_Enter:    cmp     al,13
  1354.                 jnz     @@Key_Esc
  1355.                 call    SelectFile
  1356.                 jnb     @@End
  1357.                 clc
  1358.                 ret
  1359. ;──────────────────────────────────────────────────────────
  1360. @@Key_Esc:      cmp     ah,1
  1361.                 jnz     @@End
  1362.                 stc
  1363.                 ret
  1364. ;──────────────────────────────────────────────────────────
  1365. @@Beep:         clc
  1366.                 jmp     @@End
  1367. ;──────────────────────────────────────────────────────────
  1368. @@PrintIt:      call    DisplayAll
  1369.                 clc
  1370.                 jmp     @@End
  1371. ;──────────────────────────────────────────────────────────
  1372. @@End:          jmp     @@TopLoop
  1373. endp            FileSelect
  1374.  
  1375. proc            SelectFile
  1376.                 push    ds
  1377.                 mov     ax,size FStruc
  1378.                 mul     [CurFile]
  1379.                 lds     di,[FileSeg]
  1380.                 add     di,ax
  1381.                 mov     dx,di
  1382.                 cmp     [di+FStruc.TypeOfFile],F_Directory
  1383.                 jnz     @@MustBeAModule
  1384.                 mov     AH,3Bh
  1385.                 int     21h             ;2-Change_Directory
  1386.                 call    ReadFiles
  1387.                 call    DisplayAll
  1388.                 pop     ds
  1389.                 clc
  1390.                 ret
  1391. @@MustBeAModule:
  1392.                 mov     ax,ds
  1393.                 mov     es,ax
  1394.                 pop     ds
  1395.                 stc
  1396.                 ret
  1397. endp            SelectFile
  1398.  
  1399. ;                Mode    =  0    -->  Outline
  1400. ;                           1    -->  Fill
  1401. ; cx - SizeX
  1402. ; dx - SizeY
  1403. ; ah - Color
  1404. ; al - Mode
  1405. ; di - X
  1406. ; bx - Y
  1407.                 mov     di,55
  1408.                 mov     bx,0
  1409.                 mov     ah,1Fh
  1410.                 mov     al,1
  1411.                 mov     cx,24
  1412.                 mov     dx,50
  1413. proc            DrawBox
  1414.                 push    es ax dx
  1415.                 mov     ax,[cs:Screen]
  1416.                 mov     es,ax
  1417.                 add     di,di
  1418.                 mov     ax,160
  1419.                 mul     bx
  1420.                 add     di,ax
  1421.  
  1422.                 mov     bx,160
  1423.                 sub     bx,cx
  1424.                 sub     bx,cx
  1425.  
  1426.                 cld
  1427.                 pop     dx ax
  1428.                 cmp     al,1
  1429.                 jne     @@OutlineTop
  1430.                 mov     al,' '
  1431. @@FillLoop:     push    cx
  1432.                 rep     stosw
  1433.                 add     di,bx
  1434.                 pop     cx
  1435.                 dec     dx
  1436.                 jnz     @@FillLoop
  1437.                 jmp     @@Done
  1438.  
  1439. @@OutlineTop:   push    cx
  1440.                 rep     stosb
  1441.                 add     di,bx
  1442.                 pop     cx
  1443. @@OutlineSides: stosb
  1444.                 add     di,cx
  1445.                 sub     di,2
  1446.                 stosb
  1447.                 add     di,bx
  1448.                 dec     dx
  1449.                 cmp     dx,2
  1450.                 jne     @@OutlineSides
  1451.  
  1452. @@OutlineBottom:pop     cx
  1453.                 rep     stosb
  1454.  
  1455. @@Done:         pop     es
  1456.                 ret
  1457. endp            DrawBox
  1458.  
  1459.  
  1460. proc            Main
  1461. Start:          mov     [cs:PspAddress],es
  1462.                 mov     ax,es
  1463.                 mov     bx,zzzzzseg
  1464.                 sub     bx,ax
  1465.                 add     bx,2
  1466.                 mov     [cs:SizeOfProg],bx
  1467.                 mov     ah, 4ah
  1468.                 int     21h
  1469.  
  1470.                 call    HowMuchMemory
  1471.                 call    DetermineDisplay
  1472.                 mov     ax,MyData
  1473.                 mov     ds,ax
  1474.                 mov     ah,47h
  1475.                 mov     dl,0
  1476.                 mov     si,offset HomeDirectory
  1477.                 int     21h
  1478.                 mov     ah,19h
  1479.                 int     21h
  1480.                 mov     [OldDrive],al
  1481.  
  1482.                 call    SetEnv
  1483. @@LoadDriver:   mov     si,offset SoundFile
  1484.                 call    PutName
  1485.         mov    dx,offset GDirectory
  1486.                 mov     cx,seg GDirectory
  1487.                 call    LoadSoundDriver
  1488.                 jnb     @@DriverLoaded
  1489.                 mov     dx,offset NoDriverFound
  1490.                 call    Error
  1491. @@DriverLoaded: mov     ax,[cs:GUSIRQ]
  1492.                 mov     bx,0
  1493.                 mov     cx,[cs:GUSMIDI]
  1494.                 mov     dx,[cs:GUSPort]
  1495.                 mov     si,[cs:DMAIn]
  1496.                 mov     di,[cs:DMAOut]
  1497.                 call    [dword ptr cs:Music]
  1498.                 jnb     @@FoundCard
  1499.                 mov     ah,9
  1500.                 mov     dx,offset NoGUS
  1501.                 int     21h
  1502.                 jmp     @@Quit
  1503. @@FoundCard:    mov     [cs:GUSIRQ],si
  1504.                 mov     [cs:GUSPort],di
  1505.  
  1506.                 call    SetMode
  1507.                 mov     ax,1112h
  1508.                 mov     bl,0
  1509.                 int     10h
  1510.  
  1511.                 mov     [Word cs:offset P+(offset (PM).Header)],offset Header
  1512.                 mov     [Word cs:offset P+(offset (PM).Header)+2],cs
  1513.                 mov     [Word cs:offset P+(offset (PM).PatternLoc)],offset PatternLoc
  1514.                 mov     [Word cs:offset P+(offset (PM).PatternLoc)+2],cs
  1515.                 mov     [Word cs:offset P+(offset (PM).InsLoc)],offset InsLoc
  1516.                 mov     [Word cs:offset P+(offset (PM).InsLoc)+2],cs
  1517.  
  1518.                 mov     ax,MyData
  1519.                 mov     ds,ax
  1520.                 xor     dx,dx
  1521.                 mov     ax,size FStruc
  1522.                 mov     bx,[MaxFiles]
  1523.                 mul     bx
  1524.                 mov     bx,ax
  1525.                 shr     bx,4
  1526.                 add     bx,1
  1527.                 mov     ah,48h
  1528.                 int     21h
  1529.                 mov     [Word FileSeg+2],ax
  1530.                 mov     [Word FileSeg],0
  1531.                 call    ReadFiles
  1532.  
  1533.                 mov     ah,48h
  1534.                 mov     bx,8000/16+1
  1535.                 int     21h
  1536.                 mov     [cs:ScreenFix],ax
  1537.                 mov     ax,MyData
  1538.                 mov     ds,ax
  1539.                 mov     dx,offset ScreenFilename
  1540.                 mov     ax,3D00h
  1541.                 int     21h
  1542.                 mov     bx,ax
  1543.                 mov     ax,[cs:ScreenFix]
  1544.                 mov     ds,ax
  1545.                 mov     dx,0
  1546.                 mov     cx,8000
  1547.                 mov     ax,3F00h
  1548.                 int     21h
  1549.                 mov     ax,3E00h
  1550.                 int     21h
  1551.                 call    DrawNotes
  1552.                 call    LoadFile
  1553.                 jb      @@Quit
  1554.                 call    DoIt
  1555.                 call    MUS_KillModule
  1556.  
  1557. @@Quit:         call    Terminate
  1558. endp            Main
  1559.  
  1560. ends            MyCode
  1561.  
  1562. segment         BlankMusicSeg
  1563.                 stc
  1564.                 retf
  1565. ends            BlankMusicSeg
  1566.  
  1567. segment         MyData
  1568.  
  1569. ScreenFilename  db      'SCREEN.BIN',0
  1570. Notes           db      'B-3A#3A-3G#3G-3F#3F-3E-3D#3D-3C#3C-3'
  1571.                 db      'B-2A#2A-2G#2G-2F#2F-2E-2D#2D-2C#2C-2'
  1572.                 db      'B-1A#1A-1G#1G-1F#1F-1E-1D#1D-1C#1C-1'
  1573.  
  1574. NoGUS           db      'Could not detect a Gravis Ultrasound card.',13,10,'$'
  1575. NoFileName      db      'Usage: GUSMOD filename<.mod>',13,10,'$'
  1576. NoFileFound     db      'File not found.',13,10,'$'
  1577. NoDriverFound   db      'Sound driver not found.',13,10,'$'
  1578. NoEnvFound      db      'The environment variable GUSMOD was not found.  Please add it to your',13,10
  1579.                 db      'AUTOEXEC.BAT file.  Please read GUSMOD.DOC for more information.',13,10,'$'
  1580. IllegalEnv      db      'Illegal environment variable.',13,10,'$'
  1581.  
  1582. GDirectory      db      120 dup (0)
  1583. GEnv            db      6,"GUSMOD"
  1584. PutFilename     dw      0
  1585.  
  1586. db  '\'
  1587. HomeDirectory   db      80 dup (0)
  1588. OldDrive        db      0
  1589.  
  1590. NewDTA          DTA     <>
  1591.  
  1592. MaxFiles        dw      500
  1593. NumFiles        dw      0
  1594. FileSeg         dd      0
  1595.  
  1596. WildDir         db      "*.*",0
  1597. WildMod         db      "*.MOD",0
  1598. DriveLetter     db      "-:\"
  1599. CurPath         db      65 dup (0)
  1600.  
  1601. DriveStr        db      "-:",0
  1602. DriveList       db      26 dup (0)
  1603.  
  1604. MKLine          db      9 dup (0)
  1605. Ext             db      4 dup (0)
  1606. ExtBlank        db      "~ ",0
  1607. DesBlank        db      "~ ",0
  1608.  
  1609. FileDigits      db      "0000",0
  1610.  
  1611. CurFile         dw      0
  1612. TopFile         dw      0
  1613.  
  1614. ends            MyData
  1615.  
  1616. segment         zzzzzseg
  1617.                 db      16 dup (?)
  1618. ends            zzzzzseg
  1619.  
  1620.         end     Start
  1621.  
  1622.  
  1623.